<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib uri="/authtaglib" prefix="auth" %>
<!DOCTYPE html>
<html>
<head>
<title>状态查询</title>
<style type="text/css">
.replystyle{
 margin: 0 auto;
 width: '80%';
}
.replystyle li{
margin-top:3px;
text-align: center;
font-size: 18px;
}
</style>
<jsp:include page="/include.jsp"/>
<script type="text/javascript">
function doBatchAddDatasource(){
	
	$('<div id="import"/>').dialog({
		href:"${pageContext.request.contextPath}/empHeartrateInfo/empHeartrateInfoAction!toImportPage.action",
        top: 10,
        width: 700,
        modal: true,
        title: '导入信息',
        buttons: [
           {
                id: 'btnSave',
                text: '保存',
                iconCls: '',
                handler: function () {
                    var d = $(this).closest('.window-body');
                    $('#import_form').form('submit', {
                        url: '${pageContext.request.contextPath}/cnbdw/empHeartrateInfoAction!importHeartrate.action',
                        onSubmit: function () {
                            if ($(this).form("validate")) {
                                $.messager.progress({title: '提示', text: '正在保存，请稍候 ....'});
                            } else {
                                return false;
                            }
                        },
                        success: function (result) {
                            try {
                                var r = $.parseJSON(result);
                                if (r.returnFlag) {
                                    $('#datagrid').datagrid('reload');
                                    d.dialog('destroy');
                                }
                                //显示提示信息
                                $.messager.show({
                                    title: '提示',
                                    msg: r.returnMsg
                                });
                            } catch (e) {
                            }
                            $.messager.progress('close');
                        }
                    });
                }
            },
            {
                id: 'btnCancle',
                text: '取消',
                iconCls: '',
                handler: function () {
                    $(this).closest('.window-body').dialog('destroy');
                }
            }
        ],
        onClose: function () {
            $(this).dialog('destroy');
            //刷新主列表
            $('#datagrid').datagrid('reload');
        }
    });
}


//执行查询
function doQuery() {
    if ($("#datasource_query_form").form("validate")) {
        $("#datagrid").datagrid('options').queryParams = serializeObject($('#datasource_query_form')); //把查询条件赋值给datagrid内部变量
        $("#datagrid").datagrid('load'); //重新加载
    }
}
//重置查询条件
function doReset() {
    $('#datasource_query_form').form('reset');
}
//页面加载完后响应 onReady
$(function () {
    //查询按纽绑定事件
    $('#btnQuery').bind('click', doQuery);
    //重置按纽绑定事件
    $('#btnReset').bind('click', doReset);
    //初始化主列表
    $('#datagrid').datagrid({
        url: '${pageContext.request.contextPath}/empHeartrateInfo/empHeartrateInfoAction!getAllDatasourceList.action',
        fit: true,
        border: false,
        fitColumns: true,
        pagination: true,
       
        pageList: [30, 50],
        rownumbers: false,
        sortName: 'id',
        sortOrder: 'desc',
        striped: true,
        columns: [
            [
				{field: 'heartId', checkbox: true},
                {field: 'createTime', title: '采集时间', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'empName', title: '姓名',align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'heartVal', title: '心率', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'step', title: '步数', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'elec', title: '电量', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'deviceNo', title: '设备名称',align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'mac', title: '设备地址',align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}}
            ]
        ],
        toolbar: '#datagrid_toobar'
    });
    /**
    $('#search_select_deviceType').combobox({
        url:'${pageContext.request.contextPath}/messageAction!getDeviceTypeSelectData.action',
        valueField:'id',
        textField:'name',
        editable:false
    });*/
});
function getReplyList(msgId,title){
	//alert(msgId);
	$.ajax({
        url: '${pageContext.request.contextPath}/message/messageAction!getRepllyJSON.action',
        async: false,
        data: {msgId: msgId},
        dataType: "json",
        success: function (result) {
            if(result.length > 0){
            	var content = "<ul class='replystyle'>";
            	for(var i=0; i<result.length;i++){
            		content+="<li>"+result[i].text+"<li/>";
            	}
            	content+="</ul>";
            	$('<div id="showDiv"/>').dialog({
                    top: 100,
                    width: 400,
                    modal: false,
                    content:content,
                    title: title
                });
            }else{
            	 $.messager.show({title: '提示', msg: "暂无回复!"});
            }
        }
    });
}

</script>
</head>
<body class="easyui-layout">
<form id="datasource_query_form" method="post">
    <div data-options="region:'north'" style="height:60px;border-bottom:none;border-top:none;">
        <table border="0" cellpadding="0" cellspacing="0" height="100%" width="50%">
            <tr>
                <td style="width:1%;text-align:left;" nowrap="nowrap">
                    <label for="datasource_datsourcename">姓名：</label>
                    
                    <input type="text" id="datasource_datsourcename" name="empName" class="easyui-validatebox"
                           data-options="validType:'specialCharFilter'"/>
                </td>
                <td style="width:1%;text-align:left;" nowrap="nowrap">
                    <label for="datasource_datsourcename">开始时间：</label>
                    <input id="start" name="start" type="text" class="easyui-datebox">&emsp;
                     <label for="datasource_datsourcename">结束时间：</label>
                    <input id="end" name="end" type="text" class="easyui-datebox">&emsp;
                </td>
                <td style="width:1%;text-align:left;" nowrap="nowrap">
                    <input type="button" id="btnQuery" value="查 询" class="search_btn"/>
                    <input type="button" id="btnReset" value="重 置" class="reset_btn"/>
                </td>
            </tr>
        </table>
    </div>
    <div data-options="region:'center'" style="border-top:none">
        <table id="datagrid"></table>
        <div id="datagrid_toobar" class="etl_panel_title">
            <auth:button authUrl="empHeartrateInfo/empHeartrateInfoAction!importHeartrate.action">
               <a href="javascript:void(0);" onclick="doBatchAddDatasource()" class="easyui-linkbutton"
                   data-options="iconCls:'icon-add',plain:true" style="float:left;">批量导入</a>
            </auth:button>
            <!-- 
            <div class="datagrid-btn-separator"></div>
            <auth:button authUrl="message/messageAction!delete.action">
                <a href="javascript:void(0);" onclick="doBatchDelete()" class="easyui-linkbutton"
                   data-options="iconCls:'icon-remove',plain:true">批量删除</a>
            </auth:button>
             -->
        </div>
    </div>
</form>
</body>
</html>

